#include <iostream>

using namespace std; 


int main()
{
	string a, max_a("0"); 
	int n, id, max_id=0; 

	//freopen("p1781.in", "r", stdin); 

	cin>>n; 

	for(id=1; id<=n; id++) {
		cin>>a; 
		if (a.size()>max_a.size() || (a.size()==max_a.size() && a>max_a)) {
			max_id = id; 
			max_a = a; 
		} 
	}
	cout<<max_id<<"\n"; 
	cout<<max_a<<"\n"; 
	return 0; 
}


